<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Api_Model_Message
{
	private $message_id;
	private $receiver;
	private $sender;
	private $message;
	private $status;
	private $created_time;

	public function __construct($message_row = null) {
		if(!is_null($message_row) && $message_row instanceof Zend_Db_Table_Row) {
			$this->message_id = $message_row->message_id;
			$this->receiver = $message_row->receiver;
			$this->sender = $message_row->sender;
			$this->message = $message_row->message;
			$this->status = $message_row->status;
			$this->created_time = $message_row->created_time;
		}
	}

	public function __set($name, $value) {
		switch($name) {
			case 'message_id':
				if(!is_null($this->message_id)) {
					throw new Exception('Cannot update message\'s id');
				}
				break;
			case 'receiver':
				if(!is_null($this->receiver)) {
					throw new Exception('Cannot update travel to\'s id');
				}
				break;
			case 'sender':
				if(!is_null($this->sender)) {
					throw new Exception('Cannot update from\'s id');
				}
				break;
			case 'message':
				if(!is_null($this->message)) {
					throw new Exception('Cannot update message');
				}
				break;
			case 'status':
				if(!is_null($this->status)) {
					throw new Exception('Cannot update status');
				}
				break;
			case 'created_time':
				if(!is_null($this->created_time)) {
					throw new Exception('Cannot update created_time');
				}
				break;
		}
		$this->$name = $value;
	}

	public function __get($name) {
		return $this->$name;
	}
}
